﻿@model DingTalkAgent.Web.Models.SysA_Page
@{
    ViewBag.Title = "list";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-title">
                        <h5>@Html.Label((string)ViewBag.Name)</h5>
                    </div>
                    @Html.Hidden("Page_ID", (int)ViewBag.Page_ID)
                    <div class="ibox-content">
                        <form role="form" class="form-inline" id="form1" name="form1">
                            <div class="form-group">
                                <label for="exampleInputEmail2" class="sr-only">关键字</label>
                                <input type="text" placeholder="请输入关键字" id="keyword" name="keyword" class="form-control">
                            </div>
                            <button class="btn btn-primary" type="button" onclick="add()">添加</button>
                            <button class="btn btn-white" type="button" id="btnsearch">查询</button>
                        </form>
                    </div>
                    <div class="ibox-content">
                        <div class="jqGrid_wrapper">
                            <table id="table_list_1"></table>
                            <div id="pager_list_1"></div>
                        </div>
                        <p>&nbsp;</p>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        var Page_ID = $('#Page_ID').val();
        $(document).ready(function () {

            $("#btnsearch").click(function () {
                $("#table_list_1").jqGrid('setGridParam', {
                    postData: $('#form1').serializeObject(),
                    page: 1
                }).trigger("reloadGrid"); //重新载入
            });

            $.jgrid.defaults.styleUI = 'Bootstrap';
            $("#table_list_1").jqGrid({
                url: '/SysBase/SysAList?Page_ID='+Page_ID,
                datatype: "json",
                mtype: 'Post',
                height: 'auto',
                autowidth: true,
                shrinkToFit: true,
                multiselect: true,
                multiboxonly: true,
                postData:$('#form1').serializeObject(),
                cellEdit: true,
                rowNum: 10,
                rowList: [10, 20, 30],
                colNames: ['主键编号', 'Page_ID', '动作名称', '对应Controller', '动作', '操作'],
                colModel: [
                    {
                        name: 'Act_ID',
                        index: 'Act_ID',
                        width: '15%',
                    },
                    {
                        name: 'Page_ID',
                        index: 'Page_ID',
                        width: '15%',
                    },
                    {
                        name: 'Act_Name',
                        index: 'Act_Name',
                        width: '15%',
                    },
                    {
                        name: 'Controller',
                        index: 'Controller  ',
                        width: '20%',
                    },
                    {
                        name: 'Action',
                        index: 'Action',
                        width: '15%',
                    },
                     {
                         label: '修改', name: 'Act_ID', index: 'Act_ID', width: '20%', align: 'center',
                         formatter: function (cellvalue, options, rowObject) {
                             var actionlink1 = "&apos;/SysBase/SysADelete&apos;";

                             return "<a data-toggle='modal' href='SysAEdit?ID=" + cellvalue + "' data-target='#mmXgmodal'>修改</a> | <a href='#' onclick='javascript:Delete(" + cellvalue + "," + actionlink1 + ")'>删除</a> ";
                         },
                     },
                ],
                jsonReader: {
                    root: "List",
                    page: "page",
                    total: "total",
                    records: "records",
                    repeatitems: false,
                },
                pager: "#pager_list_1",
                viewrecords: true,
                hidegrid: false,
                });
            // Add responsive to jqGrid
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_1').setGridWidth(width);
            });
            $('#mmXgmodal').on('hidden.bs.modal', function () {
                $(this).removeData('bs.modal');
            });
        });

        function add()
        {
            $("#mmXgmodal").modal({
                remote: "SysAAdd?Page_ID=" + Page_ID
            });
        }

    </script>

    <div class="modal fade" id="mmXgmodal" tabindex="-1" role="dialog" aria-labelledby="modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content  animated bounceInRight">

            </div>
        </div>
    </div>
